Add not_int intrinsic for for-loop iteration support#107
Merged
maleadt merged 2 commits intoJuliaGPU:mainfrom Mar 17, 2026
Merged
Add not_int intrinsic for for-loop iteration support#107maleadt merged 2 commits intoJuliaGPU:mainfrom
maleadt merged 2 commits intoJuliaGPU:mainfrom
Conversation
48bf507 to
6e038ef
Compare
- Handle Core.Intrinsics.not_int via xori(x, allones) in julia.jl - Enables Julia's standard `for i in 1:n` loops in kernels - Add bitwise NOT (~) codegen test - Add execution tests: for-loop with literal, constant, and dynamic bounds
6e038ef to
d7a8c24
Compare
Member
|
Test failures are tricky, and related to IR structurizing. Let's reduce the scope to just not_int for now. |
Member
|
I've copied the failing tests into maleadt/IRStructurizer.jl#1 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Julia desugars
for i in 1:nintoCore.Intrinsics.not_intto negate the loop-exit condition. Without handling this intrinsic, any kernel usingforloops hitsIRError("Unhandled Julia intrinsic: not_int").Implementation:
not_int(x)→xori(x, allones)where:xori(x, true)(logical negation)xori(x, -1)(bitwise complement, all bits set)Changes
src/compiler/intrinsics/julia.jlnot_intdispatch +emit_not_int!test/codegen/operations.jl~(bitwise NOT) codegen testtest/execution/basic.jl~execution test + 3for-loop execution testsTests
map(~, tile)bitwise NOT correctnessfor i in Int32(1):n_iters— literal boundfor i in Int32(1):Int32(n_iters)—ct.Constantboundfor j in Int32(1):len— dynamic bound from scalar indexingDepends on